# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=uriparser
pkgver=0.9.7
pkgrel=0
pkgdesc="strictly RFC 3986 compliant URI parsing and handling library"
url="https://uriparser.github.io/"
arch="all"
license="BSD-3-Clause"
makedepends="cmake gtest-dev samurai"
subpackages="$pkgname-dev lib$pkgname:libs"
source="https://github.com/uriparser/uriparser/releases/download/uriparser-$pkgver/uriparser-$pkgver.tar.bz2"

# secfixes:
#   0.9.6-r0:
#     - CVE-2021-46141
#     - CVE-2021-46142

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DURIPARSER_BUILD_DOCS=OFF \
		-DURIPARSER_BUILD_TOOLS=ON \
		-DURIPARSER_BUILD_TESTS=ON \
		-DBUILD_SHARED_LIBS=ON \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	make test ARGS=--verbose
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
7f69c9806665745c1bafe11f818434e27c2da03af387f009ef46c1427af8c008faa45e6f49bece66e0b96fd17b3924ba0af25476e796972c5e4b651f35f74c13  uriparser-0.9.7.tar.bz2
"
